/*
 Authors: ZhangXuelian
 	
 
 Changes:
 	
	
*/


#include <time.h>
#include <signal.h>
#include <sys/wait.h>
#include <errno.h>
#include <assert.h>
#include <ctype.h>
#include <stdarg.h>
#include <arpa/inet.h>
#include <sys/stat.h>
#include <fcntl.h>
#include <sys/time.h>
#include <sys/resource.h>
#include <sys/uio.h>
#include <sys/un.h>
#include <limits.h>
#include <float.h>
#include <math.h>
#include <sys/resource.h>
#include <sys/utsname.h>
#include <locale.h>
#include <sys/socket.h>

#include "coe_lib.h"
 
bool initDevice(COE_LIB * p) 
{
	// 设置log输出函数，如果不想打印log，则无需设置。
	// 建议开发在开发调试阶段开启log，在产品发布的时候禁用log。
	//coe_set_log_func(p->log_func);

	//// 初始化SDK，若初始化成功，则内部会启动一个线程去执行相关逻辑，该线程会持续运行，直到收到 exit 调用
	////int ret = coe_init_lib(&p->device_info, &p->device_notify, &p->device_data_fun);
	//if (0 == ret) {
	//	printf(" init_device success\n");
	//}
	//else 
	//{
	//	printf(" init_device failed [%d]\n", ret);
	//	return false;
	//}
	return true;
}

bool deinitDevice() 
{
	coe_deinit_lib();
	return 1;
}

// 初始化指令执行模块
COE_RECORD_HANDLER * initDeviceRecord(record_notify on_receive_record_notify)
{
	COE_RECORD_HANDLER handler = {0};
	handler.record_notify = on_receive_record_notify;
	handler.record_send = 0; // this member do not assgin value.
	return coe_init_record_module(&handler);
}

// 初始化数据采集模块
COE_CMD_HANDLER * initDeviceCmd(receive_cmd on_receive_cmd,
								cmd_send_result on_receive_cmd_result)
{
	COE_CMD_HANDLER handler = {0};
	handler.cmd_receive = on_receive_cmd;
	handler.cmd_result = on_receive_cmd_result;
	handler.cmd_send = 0; // this member do not assgin value.
	return coe_init_cmd_module(&handler);
}
